import pymysql

db = pymysql.connect(host="114.115.160.16", user="root", password="123456Aa!", database="fund")
cursor = db.cursor()

sql = "select fund_id from api_fund"
cursor.execute(sql)
funds = cursor.fetchall()

for fund in funds:
    sql = "select * from api_fundvector where fund_id='{}'".format(fund[0])
    cursor.execute(sql)
    fund_now = cursor.fetchall()
    if len(fund_now) == 0:
        sql = "insert into api_fundvector values('{}',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," \
              "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)".format(fund[0])
        cursor.execute(sql)
        db.commit()